package com.example.lab_assignment_two;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.graphics.*;
import android.view.View;
import android.view.View.*;
import android.widget.TextView;
import java.util.Random;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        
        View random_number =  findViewById(R.id.get_random_number); 
        random_number.setOnClickListener( new RandomNumberOnClickListener(0));
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

	public class RandomNumberOnClickListener implements OnClickListener {
		
		protected int number ;
		public RandomNumberOnClickListener(int n) {
			number = n;

	    }
	
		@Override
		public void onClick(View arg0) {

            Random randomGenerator = new Random();
            int randomInt = randomGenerator.nextInt(100000);
            TextView resultText = (TextView)findViewById(R.id.tex_view_random_number);
            resultText.setText("random number:"+randomInt);
		}
	
	}
	
    
}
